﻿using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sidvall.Logging
{
    public abstract class LogBase : Sidvall.Logging.ILog
    {
        #region Public Members

        public abstract Task WriteAsync(string title, string message, IEnumerable<string> categories, EventType severity, IDictionary<string, string> properties);

        #region EnabledCategories

        private LogCategoryCollection _EnabledCategories;
        public LogCategoryCollection EnabledCategories
        {
            get
            {
                return _EnabledCategories;
            }
            private set
            {
                _EnabledCategories = value;
            }
        }

        #endregion

        #region ShouldLog

        public virtual bool ShouldLog(IEnumerable<string> categories, EventType severity)
        {
            return this.EnabledCategories.Contains(categories, severity);
        }

        #endregion

        #endregion
        #region Constructors

        protected LogBase()
        {
            this.EnabledCategories = new LogCategoryCollection();
            this.EnabledCategories.AddRange(Sidvall.Logging.LogCategoryManager.GetLogCategories(), Sidvall.Logging.EventTypeManager.GetEventTypes(true, false));
        }
        protected LogBase(bool includeWarning, bool includeInformation)
        {
            this.EnabledCategories = new LogCategoryCollection();
            this.EnabledCategories.AddRange(Sidvall.Logging.LogCategoryManager.GetLogCategories(), Sidvall.Logging.EventTypeManager.GetEventTypes(includeWarning, includeInformation));
        }
        protected LogBase(IEnumerable<string> categories, IEnumerable<EventType> eventTypes)
        {
            this.EnabledCategories = new LogCategoryCollection();
            this.EnabledCategories.AddRange(categories, eventTypes);
        }

        #endregion
    }
}
